package com.sun.dao.daoimpl;

import com.sun.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AccountDaoImpl implements AccountDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    // 汇款的实现方法
    @Override
    public void out(String outUser, int money) {
        this.jdbcTemplate.update("update account set money =money-? where username =?", money, outUser);
    }

    // 收款的实现方法
    @Override
    public void in(String inUser, int money) {
        this.jdbcTemplate.update("update account set money =money+? where username =?", money, inUser);
    }
}
